// index.js
import {
  get,
  post,
  put
} from '../../utils/request'
import {
  APIS
} from '../../utils/api'
import { timestampToTime } from '../../utils/util'
// 获取应用实例
const app = getApp()

Page({
  data: {
    tabs: ['领取记录', '充值记录', '卡券纪录'],
    tabIndex: 0,
    uid: '',
    userInfo: {},
    loading: false
  },
  onLoad(opt) {
    this.setData({
      uid: opt.uid
    })
    this.getVip()
  },
  getVip() {
    get(APIS.vip + '/' + this.data.uid)
      .then(res => {
        this.setData({
          userInfo: res.data
        })
      })
  },
  handleSwitchChange(e) {
    let black = e.detail.value;
    put(APIS.vip + '/' + this.data.uid, {
      black
    })
      .then(res => {
        this.setData({
          isBlack: res.data,
          loading: false
        })
      })
  },
})